function getp(url, params) {
    return new Promise((resolve, reject) => {
        axios.get(url, {
            params: params
        }).then(res => {
            resolve(res.data);
        }).catch(err => {
            reject(err.data)
        })
    })
}

function wavePlay($canvasID, $progress, $maveColor, $time) {
    var waveAllHeight = 90
    var waveCount = 4
    var waveHeight = 15

    let _this = this;
    let waveWidth = 3300, //波浪长度
        offset = 0,

        startX = -1000,
        startY = 212, //canvas 高度
        progress = $progress, //波浪位置高度
        d2 = waveWidth / waveCount, //单个波浪的宽度
        d = d2 / 2,
        hd = d / 2,
        c = document.getElementById($canvasID),
        ctx = c.getContext("2d");
    c.width = 1920; //画布宽度
    c.height = waveAllHeight; //画布高度
    function move() {
        offset -= 5;
        if (-1 * offset === d2) {
            offset = 0;
        }
        ctx.clearRect(0, 0, c.width, c.height);
        ctx.fillStyle = $maveColor; //画布填充色
        ctx.beginPath();
        let offsetY = startY - progress;
        //绘制贝塞尔曲线
        ctx.moveTo(startX - offset, offsetY); //开始点
        for (let i = 0; i < waveCount; i++) {
            let dx = i * d2;
            let offsetX = dx + startX - offset;
            //   quadraticCurveTo(1,1,2,2) 方法通过使用表示二次贝塞尔曲线的指定控制点，向当前路径添加一个点。(1,1控制点，2,2结束点)
            ctx.quadraticCurveTo(
                offsetX + hd,
                offsetY + waveHeight,
                offsetX + d,
                offsetY
            );
            ctx.quadraticCurveTo(
                offsetX + hd + d,
                offsetY - waveHeight,
                offsetX + d2,
                offsetY
            );
        }
        ctx.lineTo(startX + waveWidth, 3000);
        ctx.lineTo(startX, 3000);
        ctx.fill();
        setTimeout(move, $time / 60); //速度
    }
    move();
}
export default {
    wavePlay,
    getp
}